def do_work(item):
    # 对参数执行的操作
    pass

def worker():
    while True:
        item = q.get()
        if item is None:
            break
        do_work(item)
        # 必须要有q.task_done()不然线程一直不结束
        q.task_done()

q = queue.Queue()

# 生成队列对象
for item in source():
    q.put(item)

threads = []
for i in range(num_worker_threads):
    t = threading.Thread(target=worker)
    # 启动线程活动
    t.start()
    threads.append(t)



# block until all tasks are done
q.join()

# stop workers
for i in range(num_worker_threads):
    q.put(None)

# 等待所有线程完成
for t in threads:
    # t.join()的意思是把线程t加入当前线程中
    t.join()


参考：https://www.huaweicloud.com/articles/e41d1539d9bf883004dd4f76034c075c.html
https://blog.csdn.net/tz_zs/article/details/98220878
https://www.runoob.com/python/python-multithreading.html